\(\int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx\) [419]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 19, antiderivative size = 29 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx=-a x-\frac {a \cot (c+d x)}{d}+\frac {b \log (\sin (c+d x))}{d} \]

[Out]

-a*x-a*cot(d*x+c)/d+b*ln(sin(d*x+c))/d

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.158, Rules used = {3610, 3612, 3556} \[ \int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx=-\frac {a \cot (c+d x)}{d}-a x+\frac {b \log (\sin (c+d x))}{d} \]

[In]

Int[Cot[c + d*x]^2*(a + b*Tan[c + d*x]),x]

[Out]

-(a*x) - (a*Cot[c + d*x])/d + (b*Log[Sin[c + d*x]])/d

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3610

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b
*c - a*d)*((a + b*Tan[e + f*x])^(m + 1)/(f*(m + 1)*(a^2 + b^2))), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e +
f*x])^(m + 1)*Simp[a*c + b*d - (b*c - a*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c
 - a*d, 0] && NeQ[a^2 + b^2, 0] && LtQ[m, -1]

Rule 3612

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c +
b*d)*(x/(a^2 + b^2)), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {a \cot (c+d x)}{d}+\int \cot (c+d x) (b-a \tan (c+d x)) \, dx \\ & = -a x-\frac {a \cot (c+d x)}{d}+b \int \cot (c+d x) \, dx \\ & = -a x-\frac {a \cot (c+d x)}{d}+\frac {b \log (\sin (c+d x))}{d} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.03 (sec) , antiderivative size = 55, normalized size of antiderivative = 1.90 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx=-\frac {a \cot (c+d x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(c+d x)\right )}{d}+\frac {b \log (\cos (c+d x))}{d}+\frac {b \log (\tan (c+d x))}{d} \]

[In]

Integrate[Cot[c + d*x]^2*(a + b*Tan[c + d*x]),x]

[Out]

-((a*Cot[c + d*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[c + d*x]^2])/d) + (b*Log[Cos[c + d*x]])/d + (b*Log[Tan[
c + d*x]])/d

Maple [A] (verified)

Time = 0.44 (sec) , antiderivative size = 42, normalized size of antiderivative = 1.45

method result size
parallelrisch \(\frac {-b \ln \left (\sec ^{2}\left (d x +c \right )\right )+2 b \ln \left (\tan \left (d x +c \right )\right )-2 a \left (d x +\cot \left (d x +c \right )\right )}{2 d}\) \(42\)
derivativedivides \(\frac {-\frac {b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}-a \arctan \left (\tan \left (d x +c \right )\right )-\frac {a}{\tan \left (d x +c \right )}+b \ln \left (\tan \left (d x +c \right )\right )}{d}\) \(50\)
default \(\frac {-\frac {b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}-a \arctan \left (\tan \left (d x +c \right )\right )-\frac {a}{\tan \left (d x +c \right )}+b \ln \left (\tan \left (d x +c \right )\right )}{d}\) \(50\)
risch \(-i b x -a x -\frac {2 i b c}{d}-\frac {2 i a}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}+\frac {b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}{d}\) \(56\)
norman \(\frac {-\frac {a}{d}-a x \tan \left (d x +c \right )}{\tan \left (d x +c \right )}+\frac {b \ln \left (\tan \left (d x +c \right )\right )}{d}-\frac {b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(57\)

[In]

int(cot(d*x+c)^2*(a+b*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

1/2*(-b*ln(sec(d*x+c)^2)+2*b*ln(tan(d*x+c))-2*a*(d*x+cot(d*x+c)))/d

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 59 vs. \(2 (29) = 58\).

Time = 0.25 (sec) , antiderivative size = 59, normalized size of antiderivative = 2.03 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx=-\frac {2 \, a d x \tan \left (d x + c\right ) - b \log \left (\frac {\tan \left (d x + c\right )^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) \tan \left (d x + c\right ) + 2 \, a}{2 \, d \tan \left (d x + c\right )} \]

[In]

integrate(cot(d*x+c)^2*(a+b*tan(d*x+c)),x, algorithm="fricas")

[Out]

-1/2*(2*a*d*x*tan(d*x + c) - b*log(tan(d*x + c)^2/(tan(d*x + c)^2 + 1))*tan(d*x + c) + 2*a)/(d*tan(d*x + c))

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 66 vs. \(2 (24) = 48\).

Time = 0.22 (sec) , antiderivative size = 66, normalized size of antiderivative = 2.28 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx=\begin {cases} \tilde {\infty } a x & \text {for}\: c = 0 \wedge d = 0 \\x \left (a + b \tan {\left (c \right )}\right ) \cot ^{2}{\left (c \right )} & \text {for}\: d = 0 \\\tilde {\infty } a x & \text {for}\: c = - d x \\- a x - \frac {a}{d \tan {\left (c + d x \right )}} - \frac {b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {b \log {\left (\tan {\left (c + d x \right )} \right )}}{d} & \text {otherwise} \end {cases} \]

[In]

integrate(cot(d*x+c)**2*(a+b*tan(d*x+c)),x)

[Out]

Piecewise((zoo*a*x, Eq(c, 0) & Eq(d, 0)), (x*(a + b*tan(c))*cot(c)**2, Eq(d, 0)), (zoo*a*x, Eq(c, -d*x)), (-a*
x - a/(d*tan(c + d*x)) - b*log(tan(c + d*x)**2 + 1)/(2*d) + b*log(tan(c + d*x))/d, True))

Maxima [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 48, normalized size of antiderivative = 1.66 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx=-\frac {2 \, {\left (d x + c\right )} a + b \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 2 \, b \log \left (\tan \left (d x + c\right )\right ) + \frac {2 \, a}{\tan \left (d x + c\right )}}{2 \, d} \]

[In]

integrate(cot(d*x+c)^2*(a+b*tan(d*x+c)),x, algorithm="maxima")

[Out]

-1/2*(2*(d*x + c)*a + b*log(tan(d*x + c)^2 + 1) - 2*b*log(tan(d*x + c)) + 2*a/tan(d*x + c))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 83 vs. \(2 (29) = 58\).

Time = 0.41 (sec) , antiderivative size = 83, normalized size of antiderivative = 2.86 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx=-\frac {2 \, {\left (d x + c\right )} a + 2 \, b \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right ) - 2 \, b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) \right |}\right ) - a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + \frac {2 \, b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + a}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}}{2 \, d} \]

[In]

integrate(cot(d*x+c)^2*(a+b*tan(d*x+c)),x, algorithm="giac")

[Out]

-1/2*(2*(d*x + c)*a + 2*b*log(tan(1/2*d*x + 1/2*c)^2 + 1) - 2*b*log(abs(tan(1/2*d*x + 1/2*c))) - a*tan(1/2*d*x
 + 1/2*c) + (2*b*tan(1/2*d*x + 1/2*c) + a)/tan(1/2*d*x + 1/2*c))/d

Mupad [B] (verification not implemented)

Time = 4.70 (sec) , antiderivative size = 70, normalized size of antiderivative = 2.41 \[ \int \cot ^2(c+d x) (a+b \tan (c+d x)) \, dx=\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (-\frac {b}{2}+\frac {a\,1{}\mathrm {i}}{2}\right )}{d}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (\frac {b}{2}+\frac {a\,1{}\mathrm {i}}{2}\right )}{d}+\frac {b\,\ln \left (\mathrm {tan}\left (c+d\,x\right )\right )}{d}-\frac {a\,\mathrm {cot}\left (c+d\,x\right )}{d} \]

[In]

int(cot(c + d*x)^2*(a + b*tan(c + d*x)),x)

[Out]

(log(tan(c + d*x) - 1i)*((a*1i)/2 - b/2))/d - (log(tan(c + d*x) + 1i)*((a*1i)/2 + b/2))/d + (b*log(tan(c + d*x
)))/d - (a*cot(c + d*x))/d